import java.util.*;
public class Test {//陈少的仓库
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        try{
            while(true){                     //while(true) 结合Scanner 实现按任意键返回
            Tools.expresstion();
            System.out.println("                   请选择操作:\n"
                            +"               1.加密\n"
                            +"               2.解密\n"
                            +"               3.判断密码强度\n"
                            +"               4.密码生成\n"
                            +"               5.退出\n");
            
            System.out.print("请输入选项序号:");
            String order = sc.next(); //读取序号,读取字符串,避免无提示抛出Exception而退出程序
            if(order.equals("1")){  //序号为1加密
                Tools.expresstion();
                System.out.print("          请输入要加密的数字密码:");
                String str = sc.next();  //读取输入
                System.out.println("          " + Tools.encryption(str)); //密码合理则调用encryption方法对密码进行加密
                
            }
            else if(order.equals("2")){ //序号为2解密
                Tools.expresstion();  //页面显示
                System.out.print("          请输入要解密的数字密码:");
                String str = sc.next();
                System.out.println("          " + Tools.decryption(str));      // 调用decryption方法解密
            }
        
            else if(order.equals("3")){   //判断密码强度
                Tools.expresstion();
                System.out.print("          请输入要判断的数字密码:");
                String str = sc.next();
                System.out.println("          " + Tools.judgePassword(str)); //调用judgePassword方法判断

            }
            
            else if(order.equals("4")){  //生成强密码
                Tools.expresstion();
                System.out.print("          请输入要生成的密码长度:");
                int passwordLength = sc.nextInt();
                System.out.println("          " + Tools.createPassword(passwordLength)); //调用createPassword方法生成
            }
            
            else if(order.equals("5")){  //序号为5抛出异常退出程序
                throw new Exception();  //抛出异常结束循环
            }
            else{
                System.out.println("          请输入正确序号.");  //序号不正确提示
            }
            System.out.print("\n          按任意键返回:");  
            sc.next();
        }

        }
        catch (Exception ex){
        }
    }
}
